Repository navigation
feat: add compile-time generators for views, AutoPersist, validation, and Android controls - #554
Merged
Merged
Conversation
… and Android controls - Add [RegisterView] and [RegisterView<TViewModel>] to generate GeneratedViewRegistrations.RegisterGeneratedViews for IReactiveUIBuilder without assembly scanning. - Add [AutoPersist] to generate static AutoPersistMetadata from [DataContract] and [DataMember] attributes at compile time. - Add [ReactiveValidation] to generate ConfigureValidation() wiring DataAnnotations attributes onto ReactiveProperty<T> properties via the reflection-free AddValidation overload. - Add [WireUpControls], [WireUpResource], and [IgnoreResource] in ReactiveUI.SourceGenerators.Android to generate compile-time FindViewById wiring. - Update public API baselines, documentation, and unit and incremental caching tests.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #554 +/- ##
==========================================
- Coverage 99.15% 99.09% -0.07%
==========================================
Files 475 487 +12
Lines 18829 19240 +411
Branches 2808 2893 +85
==========================================
+ Hits 18670 19065 +395
- Misses 159 175 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds four incremental source generators that provide compile-time, trim-safe, and Native AOT-safe replacements for reflection-based APIs being moved out of the core ReactiveUI packages.
[RegisterView]and[RegisterView<TViewModel>]to generateGeneratedViewRegistrations.RegisterGeneratedViews(this IReactiveUIBuilder)for compile-time view registration, supporting contracts and singletons without assembly scanning.[AutoPersist]to generate a staticAutoPersistMetadataproperty on partial[DataContract]classes capturing[DataMember]property names without runtime reflection.[ReactiveValidation]to generate aConfigureValidation()method that wiresDataAnnotationsvalidation attributes and[Display(Name = ...)]ontoReactiveProperty<T>properties through the reflection-freeReactivePropertyMixins.AddValidationoverload.[WireUpControls],[WireUpResource], and[IgnoreResource]inReactiveUI.SourceGenerators.Androidto generateWireUpControls()forActivity/Viewtypes andWireUpControls(View rootView)for fragments usingFindViewById<T>(Resource.Id.*).PublicAPI.txtbaselines across all target frameworks and document the new attributes in the package README.Why
As part of reactiveui/ReactiveUI#4561, reflection-based view discovery,
AutoPersist, expression-basedReactivePropertyvalidation, and AndroidControlFetcherMixinsare moving into opt-in.Unsafepackages. These generators give consumers first-class compile-time alternatives that work cleanly with trimming and Native AOT.Refs reactiveui/ReactiveUI#4561
Breaking changes
None.
How this was verified
Unit tests verify the generated output and compilation diagnostics for all four generators, and incremental caching tests verify per-type caching for
[AutoPersist],[ReactiveValidation], and[WireUpControls]. Android control wiring andReactiveValidationcompilation were exercised with in-memory stubs rather than a live Android device or an updated ReactiveUI NuGet package.Notes for the reviewer
src/ReactiveUI.SourceGenerators.Roslyn/(RegisterView,AutoPersist,ReactiveValidation, andWireUpControls) and the corresponding public attributes insrc/ReactiveUI.SourceGenerators/.PublicAPI/*/PublicAPI.txtchanges are regenerated baselines for the seven new public attribute types.ReactiveValidationGeneratortargets the AOT-safeReactivePropertyMixins.AddValidation(string? displayName, params ValidationAttribute[])overload being added alongside Apple: RoutedViewHostUnsafe and ViewModelViewHostUnsafe raise IL3050 in every native AOT app, even when unused ReactiveUI#4561.Checklist